package com.xiaotu.service.dynamic.impl;

import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.ObjectUtil;
import com.xiaotu.dao.dynamic.DynamicMapper;
import com.xiaotu.dto.IndustryDynamicDto;
import com.xiaotu.model.IndustryDynamicModel;
import com.xiaotu.service.dynamic.DynamicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @author zhangxiao
 * @create 2021-08-19 20:14
 */
@Service
@Transactional
public class DynamicServiceImpl implements DynamicService<IndustryDynamicModel> {

    @Autowired
    private DynamicMapper dynamicMapper;

    @Override
    public IndustryDynamicModel getIndustryDynamic(Integer dynamicId) {
        Validator.validateTrue(ObjectUtil.isNotNull(dynamicId), "dynamicId 不能为空");
        return dynamicMapper.selectByPrimaryKey(dynamicId);
    }

    @Override
    public List<IndustryDynamicModel> getIndustryDynamicList(IndustryDynamicDto industryDynamicDto) {
        Example example = new Example(IndustryDynamicModel.class);
        example.setOrderByClause(" publish_time desc ");
        return dynamicMapper.selectByExample(example);
    }

    @Override
    public void insertIndustryDynamic(IndustryDynamicModel add) {

    }

    @Override
    public void updateIndustryDynamic(IndustryDynamicModel upd) {

    }
}
